home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Borland C's tmpnam()
- Date: Mon, 01 Apr 96 12:41:02 GMT
- Organization: none
- Message-ID: <828362462snz@genesis.demon.co.uk>
- References: <AD84A73496681719A2@mcdiala03.it.luc.edu>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <AD84A73496681719A2@mcdiala03.it.luc.edu>
- VArase@varase.it.luc.edu "Verne Arase" writes:
-
- >In article <828276946snz@genesis.demon.co.uk>,
- >Lawrence Kirby <fred@genesis.demon.co.uk> wrote:
- >
- > >>I thought that only DOS/Intel offspring platforms were supported; that's
- > >>why I limited my query to that specific compiler; else I would've
- >included
- > >>the target environment.
- > >
- > >Don't forget that you are posting to comp.lang.c where the bias is for
- > >discussing the standard, platform-independent, C language. The place to
- > >discuss the specific traits and extensions of Borland C is somewhere
- > >like comp.os.msdos.programmer.
- >
- >Don't forget the subject line. I didn't ask a general question re:
- >tmpnam(); I put it in the context of Borland C. If I'd asked the question
- >in the context of CodeWarrior, I'd have expected someone with some
- >Macintosh experience to respond.
- >
- >The newsgroup is called comp.lang.c, not comp.lang.x-platform.c.
-
- Exactly - comp.lang.c is a platform-independent newsgroup. When you start
- asking platform-specific questions you are posting to the wrong newsgroup.
- However discussing what the standard requires is relevant to any compiler
- that claims to be conforming.
-
- > >>If you're stating that tmpnam() under Borland C does indeed check to see
- > >>that the file name is unique, I'll quash that reluctance and change the
- > >>default directory.
- > >
- > >I don't know what Borland C actually does. It it is a conforming
- > >implementation it must ensure that the name it generates is valid and
- > >doesn't already exist in the filesystem.
- >
- >Actually, it doesn't.
- >
- >All it does it insure that the file name doesn't exist in the current
- >location in the file system. Which, I'd imagine, is what just about every
- >implementation does.
-
- In a hierarchical filesystem a file is uniquely identified by its full
- path name. So to ensure "filename" doesn't already exist in the filesystem
- it just nees to ensure that, for example,
-
- fopen("filename", mode)
-
- is valid and doesn't refer to an existing file.
-
- >It's be a lot more useful if you could specify a target directory, though
- >the string that makes up that specification would be target environment
- >dependant.
-
- Unfortuately standard C has no concept of directories so this would make
- no sense as a standard C feature. If I care about what directory it goes
- in I usually care about what filename is generated and I'd generate my own.
- A bigger problem is that filename generation and (possible) creation of
- the file are distinct operations which could cause problems on a
- multitasking system. What you really need is a function that will open/create
- a new file, a bit like tmpfile() except that it also returns a file name.
- You can't write this in standard C but on systems that support a POSIX-like
- open() you can use that to build such a function.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-